FROM openjdk:11-jre as builder

WORKDIR application
ARG JAR_FILE=*.jar
COPY ${JAR_FILE} app.jar
RUN java -Djarmode=layertools -jar app.jar extract && rm app.jar

FROM openjdk:11-jre
ENV JVM_OPTS="-server -Xmx256m "
ENV PARAMS=""

WORKDIR application
COPY --from=builder /application/dependencies/ ./
COPY --from=builder /application/snapshot-dependencies/ ./
COPY --from=builder /application/spring-boot-loader/ ./
COPY --from=builder /application/application/ ./

ENTRYPOINT java ${JVM_OPTS} org.springframework.boot.loader.JarLauncher ${PARAMS}